/**
 * @Author: 焦质晔
 * @Date: 2019/6/20
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2019-08-20 11:45:10
 */
import axios from '@/api/fetch';
import * as types from './types';
import SERVER from '@/api/server';
//整理的项目事业部内容,其它的需要配合整理,未删除.
//事业部Index.vue
export const getListProjOrg =  (_params) => axios.get(`${SERVER.CMSCLOUD_MARKET}/projectProgram/getListProjOrg`, {params:_params,menuId:'-1'});
//insert ProjectOrgDTO
export const insertProjOrg = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectOrg`, params);

// infoBase.vue:得到附件,无需xml,也不用权限限制.
//得到用户基本信息 id=-9999999 后台调用系统内部的getById,so无需加权限.
export const getUserBaseInfo = id => axios.get(`${SERVER.CMSCLOUD_MARKET}/projectProgram/${id}`);
//事业部四表关联
export const selectOneByProgramId = (_params) => axios.get(`${SERVER.CMSCLOUD_MARKET}/projectProgram/selectOneByProgramId`, {params:_params,menuId:'-1'});
//dealer.vue
//getList根据提供的多个ids得到list
export const getListByDealer = (_params) => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectDealer/getListByDealer`, {params:_params,menuId:'-1'});
//全网下发-经销商列表查询
export const selectAllDealerPage = (_params) => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectDealer/selectAllDealerPageBysql`, {params:_params,menuId:'-1'});

//事业部的info.vue
export const insertDealers = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectDealer/insertFromList`, params);
export const deleteByDealerObj = id => axios.delete(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectDealer/deleteByDealerObj/${id}`);

///////////////////////////////////////////////////////////////////////////////////////////////////

















////======事业部
//updateProjectOrgStatus
export const updateProjectOrgStatus = (id, params) => axios.put(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectOrg/updateStatus/${id}`, params);
////====事业部-经销商
//getListById
// export const getListDealer =  params =>  axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectDealer`,params);
// inserts插入多条记录List<ProjectDealerDTO>
//根据projectDealerOBJ删除记录
//delete 批量
export const deleteDealers = params => axios.delete(`${SERVER.CMSCLOUD_MARKET}"/caseManager/projectDealer/batch/${params}`);

//zys 勿动，谢谢
//查询营销素材列表
// export const getMaterialList = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/material/getMaterialList`, { params });
export const getMaterialList = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/material/getMaterialList`, { params: _params, menuId: '-1' });

//营销素材数据导出
// export const getMaterialExcelList = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/material/export/excel`, params, { responseType: 'arraybuffer' });
export const getMaterialExcelList = params => {
  params = Object.assign(params, { menuId: '-1' });
  return axios({
    url: `${SERVER.CMSCLOUD_MARKET}/material/export/excel`,
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};

//营销素材数据导出模板
export const getMaterialExcelDemoList = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/material/export/excelDemo`, params, { responseType: 'arraybuffer' });

//获取营销素材附件
export const selectMaterialListByBill = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/material/getMaterialListByBill`, { params });

//营销素材编辑
export const updateMaterial = (params, id) => axios.put(`${SERVER.CMSCLOUD_MARKET}/material/update/${id}`, params);

//批量提报
export const batchHandAll = ids => axios.put(`${SERVER.CMSCLOUD_MARKET}/material/batchupdate/${ids}`);

//批量停用
export const batchtyAll = ids => axios.put(`${SERVER.CMSCLOUD_MARKET}/material/batchty/${ids}`);

//营销素材导入
export const importMaterialList = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/material/import`, params);

//打开明细获取物料对应经销商关联关系表
export const getProjectMaterialDealer = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/material/getProjectMaterialDealer`, { params });

//获取营销素材信息反馈查询列表
// export const getDealerMaterialPageBySql = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/getDealerMaterialPageBySql`, { params });
export const getDealerMaterialPageBySql = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/getDealerMaterialPageBySql`, { params: _params, menuId: '-1' });

//营销素材信息反馈查询列表导出
// export const getDealMaterialExcelList = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/export/excel`, params, { responseType: 'arraybuffer' });
export const getDealMaterialExcelList = params => {
  params = Object.assign(params, { menuId: '-1' });
  return axios({
    url: `${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/export/excel`,
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};

//营销素材信息反馈编辑
export const updateDealerMaterial = (params, id) => axios.put(`${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/update/${id}`, params);

//营销素材审核日志保存
export const saveLog = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/material/materialReviewLog/saveLog`, params);
// //  删除活动
// export const delActivity = id => axios.post(`${SERVER.INFORMATION}/activityInfo/delete?id=${id}`);
// //  查看报名情况
// export const checkSign = id => axios.get(`${SERVER.INFORMATION}/activitySign/queryActivitySignVOS?activityId=${id}`);
// //  发布活动
// export const publishActivity = id => axios.post(`${SERVER.INFORMATION}/activityInfo/publish?id=${id}`);
// //  下架活动
// export const offActivity = id => axios.post(`${SERVER.INFORMATION}/activityInfo/off?id=${id}`);
// //  停止报名
// export const stopSign = id => axios.post(`${SERVER.INFORMATION}/activityInfo/stopSign?id=${id}`);
// //  获取活动详情
// export const activityDetail = id => axios.get(`${SERVER.INFORMATION}/activityInfo/detail?id=${id}`);
// // 获取车型数据
// export const getAllModal = appId => axios.get(`${SERVER.BASEDATA}/vehicleProduct/open/getAllModel?appId=${appId}`);
